/*
 * Copyright (C) 2019 ByteDance Inc
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.bytedance.scene.ui.view;

import com.bytedance.scene.AttrUtil;
import com.bytedance.scene.StatusBarUtil;
import ohos.aafwk.ability.Ability;
import ohos.agp.components.AttrSet;
import ohos.agp.components.Component;
import ohos.agp.utils.Color;
import ohos.app.Context;

/**
 * Created by JiangQi on 8/28/18.
 */
public final class StatusBarView extends Component {
    private String mColor;
    /**
     * 构造
     *
     * @param context 上下文
     */
    public StatusBarView(Context context) {
        this(context, null);
    }

    /**
     * 构造
     *
     * @param context 上下文
     * @param attrSet attrSet
     */
    public StatusBarView(Context context, AttrSet attrSet) {
        this(context, attrSet, null);
    }

    /**
     * 构造
     *
     * @param context 上下文
     * @param attrSet attrSet
     * @param styleName styleName
     */
    public StatusBarView(Context context, AttrSet attrSet, String styleName) {
        super(context, attrSet, styleName);
        initView(context);
    }

    /**
     * 初始化属性
     *
     * @param attrSet 自定义属性
     */
    private void initTypeValue(AttrSet attrSet) {
        mColor = AttrUtil.getStringValue(attrSet,"Color","ffffff");
    }

    /**
     * 设置为沉浸式状态栏
     *
     * @param context
     */
    private void initView(Context context) {
        if(context instanceof Ability){
            Ability ability = (Ability) context;
            ability.getWindow().setStatusBarColor(Color.getIntColor(mColor));
//            StatusBarUtil.setColorForSwipeBack(ability, mColor, 38);
        }
    }


}
